<template>
  <h3>child4组件 - actions</h3>
  <div>height: {{ height }} - <button @click="fn">height*2</button></div>
</template>

<script>
import { mapState, mapActions } from "vuex";

export default {
  computed: mapState("a", ["height"]),
  // computed: mapState({
  //   height: (state) => state.a.height,
  // }),
  methods: {
    // fn() {
    //   // 组件里面可以调用dispatch方法来触发action的函数
    //   this.$store.dispatch("asyncChangeHeight", { n: 3 });
    // },

    ...mapActions("a", ["asyncChangeHeight"]),
    fn() {
      this.asyncChangeHeight({ n: 3 });
    },
  },
};
</script>
